Number System Base Conversion
Tags: #◇Computer Science #◇CSARCH1 #◇Problem Solving #◇M2
◇Overview
◇Important Formulas & Algorithms
1. Decimal to Target Base
To convert a decimal number to any target base (e.g., Binary, Octal, Hexadecimal):
- Integer Part (Whole Number):
Perform successive ("reverse") division by the target base. Write down the remainders at each step. The final result is read from the last quotient/remainder bottom-up. - Fractional Part:
Perform successive multiplication of the fraction by the target base. Extract the integer part generated at each step. Continue until the fractional part becomes zero (or until 4 decimal places for non-terminating fractions). The result is read top-down.
Example: to Binary
- Integer (6):
- remainder 0
- remainder 1
- remainder 1
- Read bottom-up:
110
- Fraction (0.625):
- (Extract 1, keep 0.250)
- (Extract 0, keep 0.500)
- (Extract 1, fraction is now 0)
- Read top-down:
.101
- Result:
◇Power-of-Two Conversions (Binary, Octal, Hex)
Because and , conversions between these bases and binary can be done directly through grouping, without routing through decimal.
Binary Octal (Base 8)
- Rule: 1 Octal digit = 3 Binary bits.
- Binary to Octal: Starting from the radix point (decimal point), group the binary bits into clusters of 3. Pad with leading/trailing zeros if necessary. Convert each 3-bit cluster into its octal equivalent.
- Example:
- Octal to Binary: Convert each octal digit directly into a 3-bit binary sequence.
- Example:
Binary Hexadecimal (Base 16)
- Rule: 1 Hexadecimal digit = 4 Binary bits (a nibble).
- Binary to Hex: Starting from the radix point, group bits into clusters of 4. Convert each nibble to its hex equivalent (0-9, A-F).
- Example:
- Hex to Binary: Convert each hex digit directly into a 4-bit binary sequence.
- Example:
Hexadecimal Octal
You cannot convert directly between Hex and Octal. You must use Binary as an intermediate bridge.
- Hex to Octal: Hex Expand to 4-bit Binary Regroup into 3-bit Octal.
- Example ():
- Hex to Bin:
- Regroup to 3s: (added trailing zero)
- Bin to Oct:
- Octal to Hex: Octal Expand to 3-bit Binary Regroup into 4-bit Hex.
◇General Base Conversion ()
To convert between two non-power-of-two bases (e.g., Base-7 to Base-5), you must use Decimal (Base 10) as the intermediate bridge.
- Step 1 (): Use positional expansion (summing digits multiplied by their positional weight ).
- Step 2 (): Use the successive division/multiplication algorithm on the resulting decimal number to reach Base Y.
◇References & Navigation
- Previous Topic: ◇Positional Number System
- Next Topic: ◇Binary Data Organization
- Related Notes: ◇Introduction to Number Systems
ACTIVE RECALL VERIFICATION
Select an answer to verify conceptual comprehension and reveal the technical rationale.
When converting a decimal fraction to another base, which arithmetic operation is successively used?
What is the binary equivalent of the decimal number 6?
What is the hexadecimal equivalent of the decimal number 314?
How many binary digits are required to represent a single octal digit?
What is the octal equivalent of the binary number 011 101 001?
How many binary digits are required to represent a single hexadecimal digit?
What is the hexadecimal equivalent of the binary number 0111 0101 1001.1011?
What is the octal equivalent of the hexadecimal number 829.A?
When converting from decimal to another base, how do you read the integer result after successive division?
What is the decimal fraction 0.625 represented in hexadecimal?